<!DOCTYPE html>
<html>
  <head>
    <title>Login/Register</title>
    <!-- 引入Bootstrap -->
    <link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/5.0.2/css/bootstrap.min.css">
    <style>
      body {
        background-color: transparent;
        background-image: url("static/login_background.jpeg");
        background-repeat: no-repeat;
        background-size: cover;
        background-position: center;
        display: flex;
        justify-content: center;
        align-items: center;
        height: 100vh;
      }
      .card {
        background-color: rgba(255, 255, 255, 0.5);
      }
      .form-control {
        background-color: transparent;
        border: none;
      }
      .btn {
        background-color: rgba(255, 255, 255, 0.5);
        border: none;
      }
      .btn-group {
        display: flex;
        justify-content: space-between;
        margin-top: 25px;
        gap: 25px;
      }
      .btn-group .btn {
        flex-basis: calc(33.33% - 8.33px);
      }
    </style>
  </head>
  <body class="bg-light">
    <div class="container">
      <div class="row justify-content-center">
        <div class="col-lg-5 col-md-7">
          <div class="card shadow-lg border-0 rounded-lg mt-5">
            <div class="card-header">
              <h3 class="text-center font-weight-light my-4">基于SM4的医疗卫生保障系统</h3>
            </div>
            <div class="card-body">
              <form method="post" action="/login">
                <div class="form-floating mb-3">
                  <input class="form-control" id="username" name="username" type="text" placeholder="Username" value="{{ username }}" required>
                  <label for="username">请输入用户名</label>
                </div>
                <div class="form-floating mb-3">
                  <input class="form-control" id="password" name="password" type="password" placeholder="Password" required>
                  <label for="password">请输入密码</label>
                </div>
                {% if error_msg %}
                <div class="alert alert-danger">{{ error_msg }}</div>
                {% endif %}
                <div class="form-floating mb-3">
                  <select class="form-select" id="identity" name="identity" required>
                    <option value="" disabled selected></option>
                    <option value="radiologist">放射科医生</option>
                    <option value="outpatient_doctor">门诊部医生</option>
                    <option value="admin">系统管理员</option>
                  </select>
                  <label for="identity">请选择你的身份</label>
                </div>
                <!-- 新增一个隐藏的 input 来传递身份选择的值 -->
                <input type="hidden" id="selected_identity" name="selected_identity">
                <div class="text-center">
                  <button class="btn btn-light" type="submit" style="width: 100%;" onclick="setSelectedIdentity()">Login</button>
                </div>
              </form>
            </div>
          </div>
        </div>
      </div>
    </div>
    <!-- 引入Bootstrap的JS文件 -->
    <script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/5.0.2/js/bootstrap.min.js"></script>
    <!-- JavaScript 代码用于设置隐藏的身份选择值 -->
    <script>
      function setSelectedIdentity() {
        const identitySelect = document.getElementById('identity');
        const selectedIdentity = identitySelect.value;
        document.getElementById('selected_identity').value = selectedIdentity;
      }
    </script>
  </body>
</html>